//
//  ZZCTransactionRecordController.m
//  ZZC-Finance
//
//  Created by mac on 2017/5/24.
//  Copyright © 2017年 mac. All rights reserved.
//

#import "ZZCTransactionRecordController.h"
#import "ZZCTRRefundController.h"
#import "ZZCTRQuotaController.h"
#import "ZZCTRUbiController.h"
#import "ZZCTransactionRecordView.h"
#import "ZZCTRSiftController.h"

@interface ZZCTransactionRecordController ()<ZZCBaseSelectControllerDelegate,ZZCBaseSelectControllerDataSource>
@property (strong, nonatomic) NSArray *titles;
@property (strong, nonatomic) NSArray *controllers;
@property (assign, nonatomic) NSInteger selectVCIndex;//选中的控制器号
@property (strong, nonatomic) ZZCTransactionRecordView *TRView;

@end

@implementation ZZCTransactionRecordController
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithHex:0xEAEAEA];
    self.navigationItem.title = @"交易记录";
//    if (self.isLogin) {
        self.selectVCIndex = 0;
        self.datasouce = self;
        self.delegate = self;
        
//        self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithName:@"筛选" target:self action:@selector(choose)];
        ZZCTRUbiController *ubi = [ZZCTRUbiController new];
        ubi.parentController = self;
        
        ZZCTRRefundController *refund = [ZZCTRRefundController new];
        refund.parentController = self;
        
        ZZCTRQuotaController *quo = [ZZCTRQuotaController new];
        quo.parentController = self;
        
        
        self.titles      = @[@"U币",@"还款",@"额度"];
        self.controllers = @[ubi,refund,quo];
        
        [self addChildViewController:ubi];
        [self addChildViewController:quo];
        
        [self reloadData];
//    }else {
//        [self.view addSubview:self.TRView];
//        [self.TRView.TRBtn addTarget:self action:@selector(TRBtnClick) forControlEvents:UIControlEventTouchUpInside];
//    }
    
}

//登录点击
- (void)TRBtnClick {
    ZZCLoginController *login = [ZZCLoginController new];
    [self.navigationController pushViewController:login animated:YES];
}

//筛选
- (void)choose {
    ZZCTRSiftController *sift = [ZZCTRSiftController new];
    [self.navigationController pushViewController:sift animated:YES];
}

#pragma mark -dataSouce
- (NSInteger)numberOfPageInZZCBaseSelectController:(ZZCBaseSelectController *)baseSelectController {
    return self.titles.count;
}
- (UIViewController *)baseSelectController:(ZZCBaseSelectController *)baseSelectController controllerAtIndex:(NSInteger)index{
    return self.controllers[index];
}
- (NSString *)baseSelectController:(ZZCBaseSelectController *)baseSelectController titleAtIndex:(NSInteger)index{
    return self.titles[index];
}

- (UIColor *)titleNomalColorInZZCBaseSelectController:(ZZCBaseSelectController *)baseSelectController {
    return [UIColor colorWithHex:0x333333];
}
- (UIColor *)titleSelectedColorInZZCBaseSelectController:(ZZCBaseSelectController *)baseSelectController {
    return [UIColor colorWithHex:0x333333];
}

- (UIColor *)lineColorInZZCBaseSelectController:(ZZCBaseSelectController *)baseSelectController {
    return [UIColor colorWithHex:0xff704a];
}
- (CGFloat)titleFontInZZCBaseSelectController:(ZZCBaseSelectController *)baseSelectController {
    return 18;
}



#pragma mark - delegate
- (void)baseSelectController:(ZZCBaseSelectController *)baseSelectController selectedIndex:(NSInteger)index{
    // presentIndex
    self.selectVCIndex = index;
    
}
- (void)baseSelectController:(ZZCBaseSelectController *)baseSelectController selectedController:(UIViewController *)controller{
    // presentController
}
- (void)baseSelectController:(ZZCBaseSelectController *)baseSelectController selectedTitle:(NSString *)title{
    // presentTitle
}

- (ZZCTransactionRecordView *)TRView {
    if (_TRView == nil) {
        _TRView = [ZZCTransactionRecordView transactionRecordView];
        _TRView.frame = CGRectMake(0, 0, ZZCScreenW, ZZCScreenH);
    }
    return _TRView;
}
@end
